/*
 * @Author: muuzi@163.com muuzi@163.com
 * @Date: 2024-12-04 22:55:50
 * @LastEditors: muuzi@163.com muuzi@163.com
 * @LastEditTime: 2024-12-15 22:37:13
 * @FilePath: /mp-wechat/mock/user.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// mock/user.ts

import { resultSuccess } from "../_util"

const createMembersList = () => {
    return [
        {
            memberId: 1,
            levelId: '1',
            nickname: 'wendy',
            levelname: '黄金',
            phone:'1211111111',
            token: 'Admin Token',
            integral:140
        },
        {
            memberId: 2,
            levelId: '2',
            nickname: 'wendy',
            levelname: '黄金',
            phone:'1311111111',
            token: 'Admin Token',
            integral:120
        }
    ]
}
export default [

    // 获取用户信息接口
    {
        url: '/members/info',
        method: 'get',
        response: (request: any) => {
           
            // 获取请求头携带的 token
            const token = request.headers.authorization
            console.log('token=====',token)
            // 查看用户信息数据中是否包含有此 token 的用户
            const checkUser = createMembersList().find((item) => "Bearer " + item.token === token)
            // 没有就返回失败信息
            if (!token) {
                return {
                    code: 201,
                    data: {
                        msg: '获取会员信息失败'
                    }
                }
            }
            // 有就返回成功信息
            return resultSuccess(checkUser)
            // return {
            //     code: 200,
            //     data: {
            //         checkUser
            //     }
            // }
        }
    }
]
